<?php
	/**
	 *	Wap Portal Server
	 *
	 *	Copyright (C) 2002 - 2004 Emir Sakic
	 *
	 *	Wap Portal Server
	 *	Developer: Emir Sakic - saka@hotmail.com
	 *  Homepage: http://www.sakic.net
	 *	Date: 15/03/2004
	 * 	Version #: 1.2
	**/

$query = "SELECT * FROM wps_items WHERE id = '$id'";
$result = mysql_query($query);
$row = mysql_fetch_object ($result);

echo "<card id=\"Card1\" title=\"$row->title\">\n";
echo "<p>\n";

if (empty($offset)) {
	$offset = 0;
}

// Strip all HTML tags
$content = strip_tags($row->content);
// Split long content in arrays (lenght 500 chars)
$content = split_in_array($content, 500);
// Replace new lines with branches
//$content[$offset] = ereg_replace("(\r\n|\n|\r)", "<br />\n", $content[$offset]);
$content[$offset] = preg_replace("/(\015\012)|(\015)|(\012)/", "<br />\n", $content[$offset]);
// Parse UBB code
$content[$offset] = parseUBB($content[$offset]);

// Display
echo $content[$offset];

$prev = $offset-1;
$next = $offset+1;

if (strlen($content[$next]) > 0) {
	echo "-";
}
if (strlen($content[$prev]) > 0 || strlen($content[$next]) > 0) {
	echo "<br />";
}

if (strlen($content[$prev]) > 0) {
	echo "
		<anchor>"._PREV_STR."
			<go href=\"index.php\">
				<postfield name=\"option\" value=\"section\" />
		  		<postfield name=\"itemid\" value=\"$row->id\" />
		  		<postfield name=\"offset\" value=\"$prev\" />
			</go>
		</anchor>&nbsp;";
}

if (strlen($content[$next]) > 0) {
	echo "
		<anchor>"._NEXT_STR."
			<go href=\"index.php\">
				<postfield name=\"option\" value=\"section\" />
		  		<postfield name=\"itemid\" value=\"$row->id\" />
		  		<postfield name=\"offset\" value=\"$next\" />
			</go>
		</anchor>";
}

echo "</p>\n";
echo "<p align=\"center\">\n";
echo "<anchor>"._HOME."\n";
echo "<go href=\"index.php\">\n";
echo "</go>\n";
echo "</anchor>\n";
echo "</p>\n";
echo "</card>\n";